package com.dmz.workflow.controller;

import java.util.List;

import com.dmz.workflow.req.BranchPredictionReq;
import com.echronos.commons.Result;
import com.dmz.workflow.service.ProcessDefinitionService;
import com.dmz.workflow.service.WorkflowDiscussionService;
import com.dmz.workflow.vo.DiscussionVo;
import com.dmz.workflow.vo.IntermediateNodeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 评论和预判
 **/
@RestController
@RequestMapping("/v1/flowable/processDefinitionJob")
public class CommentAndPredictionController {

    @Autowired
    private ProcessDefinitionService processDefinitionService;

    @Autowired
    private WorkflowDiscussionService workflowDiscussionService;

    /**
     * 根据用户填写值预判流程的审批节点
     **/
    @PostMapping("/userInputByValue")
    public Result<List<IntermediateNodeVo>> userInputByValue(@RequestBody BranchPredictionReq branchPredictionReq) {
        return processDefinitionService.userInputByValue(branchPredictionReq);
    }

    /**
     * 添加评论接口
     */
    @PostMapping("/saveDiscussion")
    public Result<?> saveDiscussion(@RequestBody DiscussionVo discussionVO) {
        workflowDiscussionService.saveDiscussion(discussionVO);
        return Result.build();
    }
}
